//意向客户管理
;
var _pageUrl = "/htmlWeb/custom/list";
var pageGrid;
function getParam() {
    return {
        curPage: curPage <= 1 ? 1 : curPage,
        pageSize: pageSize,
        status:$("#status").val(),
        name:$("#name").val(),
        position_id:1002,
        parent_id:$("#parent_id").val()}
}
function contact(index) {
    alert();
}
function distribut(index) {
    $(".deskDiv").css({
        display:"block",height:$(document).height()
    });
    $(".distribut").css({
        top:($(window).height()-$(".distribut").height())/2+$(window).scrollTop()+"px",
        display:"block"
    });
}
function gotoHtml(index, type) {
    $.ajaxSetup({cache: false});
    $(".mainDiv").load('htmlWeb/systemKeywordNewHtml', '', function () {
        $("#id").val(index);
        $("#opType").val(type);
        $.getScript("../../by-webhtml/assets/js/system/system_keywordNew.js");
    });
}
function init() {
    _init_area();
    $.post("htmlWeb/keyword/getOption", function (data) {
        var _noOpt = "", _keyParent = "";
        $.each(data.status, function (index, obj) {
            var opt = obj.split(";");
            _noOpt += '<option value="' + opt[0] + '">' + opt[1] + '</option>'
        });
        $.each(data.parentId, function (index, obj) {
            _keyParent += '<option value="' + obj.id + '">' + obj.name + '</option>'
        });
        $("#parentId").append(_keyParent);
        $("#status").append(_noOpt);
    });
    $("#add").click(function () {
        gotoHtml(null, 0);
    });
    $(".conBut").click(function () {
        pageGrid.search({name:$("#name").val()});
    });
}
function pageBar() {
    pageGrid=  $("#pager").createPage({
        url: _pageUrl,
        ajaxBackFn: function (data) {
            var _gridHtml = '';
            $.each(data.rows, function (index, row) {
                _gridHtml += '<tr>' +
                    '<td><input type="hidden" class="rowid" value=\"' + row.id + '\"><p>' + row.id + '</p></td>' +
                    '<td><p>' + row.contact + '</p></td>' +
                    '<td><p>' + row.mobile + '</p></td>' +
                    '<td><p>' + row.province + '</p></td>' +
                    '<td><p>' + row.city + '</p></td>' +
                    '<td><p>' + row.district + '</p></td>' +
                    '<td><p>' + row.descn + '</p></td>' +
                    '<td><p>' + row.statusName + '</p></td>' +
                    // '<td><span class="userSpan"><p>' +
                    // '<a href="javascript:contact(' + row.id + ')">联系</a>' +
                    // '<a class="ico" href="javascript:distribut(' + row.id + ')">分配</a>' +
                    // '</p></span></td>' +
                    '</tr>';
            });
            $("#customGrid tr:not(:first)").html("");
            $('#customGrid').append(_gridHtml);
        }
    });
}
$(function () {
    init();
    pageBar();
});